﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Gebra.Test
{
    [TestClass]
    public class ExponentTest
    {
        [TestMethod]
        public void ConstructWithNumbers()
        {
            var operand = new Exponent((Number) 6, (Number) 2);

            var result = operand.Evaluate() as Number;

            Assert.IsNotNull(result);
            Assert.AreEqual(36, (double)result);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ConstructWithNullRoot()
        {
            new Exponent(a_root: null, a_power: (Number) 2);
        }

        [TestMethod]
        [ExpectedException(typeof(ArgumentNullException))]
        public void ConstructWithNullPower()
        {
            new Exponent((Number) 6, a_power: null);
        }
        
        [TestMethod]
        public void EvaluateThreePowers()
        {
            // 2 ^ 2 ^ 2 = 16
            var operand = new Number(2).Raise(2.0).Raise(2.0);

            var result = operand.Evaluate() as Number;

            Assert.IsNotNull(result);
            Assert.AreEqual(16, (double)result);
        }
    }
}
